English
Install Conda packages
Due to an institutional-level block by Anaconda towards BSC, caused by a change in service policies, it is currently not possible to create, update, or modify conda environments using the defaults channel. This does not affect other channels, such as bioconda or conda-forge, which contain the majority of used packages. Below is a method to solve this issue.
Requirements to install packages
Requirements to install packages networked (must have Internet access)
Connect to login0 of MareNostrum4:
mylaptop$> ssh {username}@mn0.bsc.es
IMPORTANTThe MareNostrum4 login0 is restricted to BSC staff and is only accessible from the BSC internal network or the Virtual Private Network (VPN).
Check the Internet connectivity from login0, for example:
$> wget --tries=3 --timeout=5 -q --spider google.com && echo "Networked" || echo "Non-networked"
Networked
Check the package manager
conda is a package manager that helps you install packages under Anaconda or Miniconda (a mini version of Anaconda that includes just conda, its dependencies, and Python)
Load Anaconda/Miniconda in the session, for example:
$> module load miniconda3
Ensure you can run conda from the command line:
$> which conda
/apps/MINICONDA3/py39_4.10.3/bin/conda
$> conda --version
conda 4.10.3
Remove defaults from the Anaconda channel list:
This step must be performed once a conda module is loaded and will prevent commands from timing out:
$> conda config --remove channels defaults
Optionally, other channels can be added to prevent conda from attempting to retrieve from defaults when no there's no specified channel.
$> conda config --add channels conda-forge
$> conda config --add channels bioconda
Install and manage packages
Install packages from Anaconda.org
Install a package:
$> conda install SomePackage # Latest version
$> conda install SomePackage=0.15.0 # Specific version
$> conda install SomePackage py38_env # Specific Python version
$> conda install SomePackage=0.15.0 py38_envOr:
$> conda install -c SomeChannel SomePackage # From a specific channel on Anaconda.org
$> conda install --name myenv SomePackage # Into an existing environment "myenv" (also -n)Install multiple packages at once:
$> conda install A B C D
Install non-conda packages
Both pip and python are included in Anaconda/Miniconda so that you can install packages the same as at:
pip packages do not have all the features of conda packages, so it's recommended first try to install any package with conda
Update packages
Update a package:
$> conda update SomePackage
Remove packages
Remove one or more packages:
$> conda remove SomePackage
$> conda remove -n myenv SomePackage
$> conda remove A B C D
Check installed packages
View the list of installed packages
$> conda list
$> conda list -n myenv # For an existing environment "myenv"
Work with environments
Create environments
Create an environment (at the default location, you may not have enough permissions):
$> conda create --name myenv
$> conda create -n myenvCreate an environment in a custom location:
$> conda create --prefix /path/to/my/project/myenv
$> conda create -p /path/to/my/project/myenvCreate an environment with a specific version of Python and multiple packages:
$> conda create -n myenv python=3.9 A=0.15.0 B=0.21 C D
Create an environment from an environment.yml file:
$> conda env create -f environment.yml
Activate/deactivate environments
Activate a environment:
$> conda activate myenv # By name
$> conda activate /path/to/my/project/myenv # By prefixOr:
$> source activate myenv
$> source activate /path/to/my/project/myenv
Deactivate a environment:
$> conda deactivate
Check existing environments
View the list of the existing environments:
$> conda env list
Or:
$> conda info --envs
Remove environments
Remove a environment:
$> conda remove --name myenv --all
$> conda remove -p /path/to/my/project/myenv --allOr:
$> conda env remove -n myenv
$> conda env remove -p /path/to/my/project/myenv